<template>
	<div>
		<el-dialog :title="title" :visible.sync="dialogVisible" size="large" :close-on-press-escape="false" :before-close="off" :show-close="true" :top="dialog_margin_top">

			<el-table :data="tableData" border style="width: 100%;" :height="tableHeight" :highlight-current-row="true">
				<el-table-column prop="rowidObject" label="日志编号" width="160"></el-table-column>
				<el-table-column prop="businessname" label="业务名称" show-overflow-tooltip min-width="200"></el-table-column>
				<el-table-column prop="createdate" label="修改时间" :formatter="dateFormater" width="250"></el-table-column>
				<el-table-column prop="createdby" label="修改人" show-overflow-tooltip min-width="100"></el-table-column>
				<el-table-column prop="validstatus" label="操作" width="120">
					<template scope="scope">
						<el-button type="button" class="el-button el-button--default el-button--small" @click="viewLogDetail(scope.row)"><i class="fa fa-eye"></i> 查看详情</el-button>
					</template>
				</el-table-column>
			</el-table>

			<div class="block" style="float:right">
			    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
			      :current-page="formData.currentPage"
			      :page-sizes="[15, 30, 45]"
			      :page-size="formData.pageSize"
			      layout="total, sizes, prev, pager, next, jumper"
			      :total="total">
			    </el-pagination>
			</div>

			<span slot="footer" class="dialog-footer">
			   <el-button @click="off()">关闭</el-button>
			</span>
		</el-dialog>
		<LogDetail v-if="showLogDetailDialog"></LogDetail>
	</div>

</template>

<script>
import LogAPI from "../../../js/production/log/logAPI"
import dateUtil from "../../../common/js/dateUtil"
import Utils from"../../../js/production/utils";
import LogDetail from "./LogDetail";
export default {
  components : {
  	LogDetail
  },
  data () {
    	return {
    		formData: {
    		        currentPage: 1,
	                    pageSize: 15,
	                    orderBy: '',
	                    order: '',
	                    businessKeyValue: '',
	                    logId :'',
    		},
    		tableData: [],
    		total: 0,
		isSortRequest: false,	//是否请求 
		tableHeight: 0,
		dialogVisible: true,
		showLogDetailDialog : false,
		dialog_margin_top: '10%',
		title : '',
		rowdata: {},
	}
  },
  mounted() {
  	this.tableHeight = Utils.getScreenHeight()*0.6;
  	this.formData.businessKeyValue = this.$parent.logBusinessKeyValue;
  	this.title = '【' + this.formData.businessKeyValue + '-' + this.$parent.logBusinessKey + '】操作日志';
  	this.queryData();
  },
  methods: {
		queryData() {
			LogAPI.query(this);
		},
		handleSizeChange(val) {
			this.formData.pageSize = val;
			this.queryData();
		},
		handleCurrentChange(val) {
			this.formData.currentPage = val;
			this.queryData();
		},
		dateFormater(row,  column) {  
			var  date  =  row[column.property];            
			if  (date  ==  undefined)  {               
				return  "";            
			}  
			return Utils.getDateTime(date);
		},
		off() {
			this.$parent.showLogDialog = false;
		},
		viewLogDetail(row) {
			this.formData.logId = row.rowidObject;
			this.rowdata = row;
			LogAPI.openLogDetailDialog(this);
		}
  }
}
</script>